package com.ss.android.article.base.app;

import android.content.Context;
import android.net.http.HttpResponseCache;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;

import com.bytedance.article.b.a.o;
import com.bytedance.article.common.a.g;
import com.bytedance.frameworks.b.a.ComponentsManifest;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.ss.android.a.AbManager;
import com.ss.android.action.b.ImpressionHelper;
import com.ss.android.article.base.feature.detail2.DetailIntentCreator;
import com.ss.android.article.base.feature.shrink.extend.ArticleBaseExtendManager;
import com.ss.android.article.base.utils.e;
import com.ss.android.common.shrink.extend.CoreExtendSdkManager;
import com.ss.android.common.util.ImmersedStatusBarHelper;
import com.ss.android.common.util.ToolUtils;
import com.ss.android.image.FrescoUtils;
import com.ss.android.newmedia.MediaAppData;
import com.ss.android.newmedia.BaseApplication;

import java.io.File;

import inline.SearchDemo;

public abstract class BizApplication extends BaseApplication {
    private static boolean f = true;

    public BizApplication(String arg2, String arg3, String arg4, int arg5) {
        super(arg2, arg3, arg4, arg5);
        new Handler();
        e.a(10001);
    }

    public final void e() {
        super.e();
        try {
            HttpResponseCache.install(new File(ToolUtils.getInternalCacheDir(this), "ss-http-cache-v2"), 10485760);
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public final String getAbClient() {
        int v4 = 0;
        int v5 = 0;
        String v0_2;
        AppData v7 = null;
        int v0 = 1;
        StringBuilder v6 = new StringBuilder();
        try {
            v7 = AppData.getInstance();
            if (!v7.cK) {
                v0_2 = null;
                return v0_2;
            }

            if (v7.B() == 1) {
                v5 = 1;
            } else {
                v5 = 0;
            }

//            goto label_12;
        } catch (Exception v0_1) {
//            goto label_95;
        }

        try {
            if (v7.videoOntab == 1) {
                v4 = 1;
            } else {
                v4 = 0;
            }
//            goto label_15;
        } catch (Exception v0_1) {
//            goto label_95;
        }
        try {
//            label_15:
            boolean v8 = v7.D();
            String v2 = v5 != 0 ? "a1" : "a2";
            v6.append(v2);
            v6.append(",");
            v2 = "c2";
            if (v5 == 0 || !v7.U()) {
                if (v5 != 0 && ((v7.y & 1) <= 0 && v7.z == 2)) {
                    v2 = "c3";
                } else {
                    label_77:
                    if (v5 == 0) {
//                    goto label_26;
                    } else {
                        SearchDemo.b();
                        if (SearchDemo.e != 3) {
//                    goto label_26;
                        } else {
                            v2 = "c4";
                        }
                    }
                }
            } else {
                v2 = "c1";
            }

            label_26:
            v6.append(v2);
            v6.append(",");
            v2 = v4 != 0 ? "e1" : "e2";
            v6.append(v2);
            v6.append(",");
            v2 = v5 == 0 || !v8 ? "f1" : "f2";
            v6.append(v2);
            if (v5 != 0) {
                int v2_1 = v7.C > 0 ? 1 : 0;
                if (v2_1 == 0) {
                    v0 = 0;
                }
            } else {
                label_90:
                v0 = 0;
            }

            v6.append(",");
            v0_2 = v0 != 0 ? "g1" : "g2";
            v6.append(v0_2);
            v6.append(",");
            v6.append("f7");
        } catch (Exception v0_1) {
            v0_1.printStackTrace();
        }

        return v6.toString();
    }

    public final long getAbFlag() {
        long v0 = 0L;
        try {
            v0 = ((long) AppData.getInstance().C());
        } catch (Exception v2) {
        }

        return v0;
    }

    public final String getAbVersion() {
        AbManager v0 = AbManager.getInstance(this);
        String v0_1 = !v0.c ? null : v0.abVersion;
        return v0_1;
    }

    public final String getAbGroup() {
        return AbManager.getInstance(this).a();
    }

    public final String getAbFeature() {
        return AbManager.getInstance(this).b();
    }

    public static boolean k() {
        return BizApplication.f;
    }

    public final void loadDepend() {
        com.ss.android.article.common.b.b v1;
        super.loadDepend();
        try {
            v1 = com.ss.android.article.common.b.b.a();
            if (v1.a != null) {
            } else if (TextUtils.isEmpty("com.ss.android.topic.bb")) {
            } else {
                Object v0_1 = Class.forName("com.ss.android.topic.bb").newInstance();
                if (!(v0_1 instanceof com.ss.android.article.common.b.a)) {

                } else {
                    v1.a = ((com.ss.android.article.common.b.a) v0_1);
                }
            }
        } catch (Throwable v0) {
            Log.d("DexParty", "load TopicDependManager exception: " + v0);
        } finally {
            try {
                o.a().b();
            } catch (Throwable v0) {
                BizApplication.f = false;
            }
        }
    }

    public void onCreate() {
        com.ss.android.l.c.c();
        if (!BizApplication.b) {
            this.A();
        }

        CoreExtendSdkManager v0 = ArticleBaseExtendManager.getInstance();
        this.getApplicationContext();
        v0.loadBaiduStatisticsAdapter();
        super.onCreate();
        System.currentTimeMillis();
        if (!ToolUtils.isMainProcess(((Context) this))) {
            e.b();
        } else {
            if (BizApplication.b) {
                ComponentsManifest.addComponent(ImmersedStatusBarHelper.IStatusBarConfig.class, AppData.getInstance().getAbSettings());
            } else {
                com.ss.android.account.v2.aa v0_1 = com.ss.android.account.v2.aa.getInstance();
                ((com.ss.android.account.v2.bb) v0_1).a(new com.ss.android.article.base.app.account.a(((Context) this)));
                ComponentsManifest.addComponent(com.ss.android.account.v2.bb.class, v0_1);
                ComponentsManifest.addComponent(com.ss.android.newmedia.c.a.class, new t());
                ComponentsManifest.addComponent(DetailIntentCreator.class, com.ss.android.article.common.e.a.a().b());
                ComponentsManifest.addComponent(ImmersedStatusBarHelper.IStatusBarConfig.class, AppData.getInstance().getAbSettings());
                com.ss.android.article.base.utils.a.b.migrateSp();
                PullToRefreshBase.setAnimationStyle(new i());
            }

            ImpressionHelper.getInstance().f = new ImpressionHelper.e$b();
            com.ss.android.l.c.c();
            MediaAppData mediaAppData = MediaAppData.provide();
            if (mediaAppData.mContext != null) {
                mediaAppData.mMonitorImageFrescoSwitch = mediaAppData.mContext
                        .getSharedPreferences("app_setting", Context.MODE_PRIVATE)
                        .getInt("monitor_image_fresco_SWITCH", 1);
            }

            FrescoUtils.init(this);
            com.ss.android.l.c.c();
            com.bytedance.article.common.a.e v0_3 = g.a;
            com.bytedance.article.common.a.e.a v1 = new com.bytedance.article.common.a.e.a();
            if (v0_3.a == null) {
                v0_3.a = v1;
            }

            com.ss.android.l.c.c();
            com.ss.android.l.c.c();
        }
    }
}

